home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / SAT / SAT Invaders sample ƒ / sShot.p < prev   
Encoding:
Text File  |  1993-09-19  |  1.4 KB  |  62 lines  |  [TEXT/PJMM]

  1. {===============================================}
  2. {================= Shot sprite unit ================}
  3. {===============================================}
  4.  
  5. { Example file for Ingemars Sprite Animation Toolkit. }
  6. { © Ingemar Ragnemalm 1992 }
  7. { See doc files for legal terms for using this code. }
  8.  
  9. unit sShot;
  10.  
  11. { Sprite unit. A sprite unit should include the following routines:}
  12. { Init-procedure, that initializes private bitmaps}
  13. { Setup-procedure, that sets variables other than the standard ones set by MakeSprite }
  14. { Handle-procedure, to be called once per iteration until the sprite dies }
  15. { Hittask-procedure (optional), for advanced collission handling. }
  16.  
  17. { Shot object for the SATInvaders sample game. }
  18.  
  19. interface
  20.  
  21.     uses
  22.         SAT, SoundConst, GameGlobals;
  23.  
  24.     procedure InitShot;
  25.     procedure SetupShot (sp: SpritePtr);
  26.     procedure HandleShot (me: SpritePtr);
  27.  
  28. implementation
  29.  
  30.     const
  31.         shotSpeed = 15;
  32.  
  33.     var
  34.         shotFace: FacePtr;
  35.  
  36.     procedure InitShot;
  37.         var
  38.             h: Handle;
  39.     begin
  40.         shotFace := GetFace(135);
  41.     end;
  42.  
  43.     procedure SetupShot (sp: SpritePtr);
  44.     begin
  45.         sp^.face := shotFace;
  46.         SetRect(sp^.hotRect, 0, 0, 8, 12);
  47.     end;
  48.  
  49.     procedure HandleShot (me: SpritePtr);
  50.     begin
  51.         if me^.kind <> 1 then
  52.             begin
  53.                 me^.task := nil;
  54. {No sound here - we assume that the bad guys (sEnemy and sMissile) do that }
  55.             end;
  56.  
  57.         me^.position.v := me^.position.v - shotSpeed;
  58.         if me^.position.v < 0 then
  59.             me^.task := nil;
  60.     end;
  61.  
  62. end.